﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_GetPositionFromStaff]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_GetPositionFromStaff];
GO
CREATE PROCEDURE [dbo].[sproc_GetPositionFromStaff]
    @staffid int, --人员id
    @Positionid int output --返回的职位id
as
BEGIN
SET NOCOUNT ON;

SELECT
    @PositionID = b.Position_id
FROM
    dbo.uds_staff a,
    dbo.uds_staff_in_position b
WHERE
    a.Staff_ID = b.Staff_ID
    and a.Staff_ID = @staffid;

if(@@rowcount = 0)
    return 1;

return 0;

END
GO